ans=[]
visit = [True, True, True,True]
temp = ["" for x in range(0, 4)]

# def opera(now):

def dfs(position):#求全排列
    if position == len(arr):
        print(temp)
        #num_qpl.append(temp)
        return
    for index in range(0,len(arr)):
        if visit[index] == True:
            temp[position] = arr[index]
            visit[index] = False
            dfs(position + 1)
            visit[index] = True

def fuhao_hebin_arr(fuhao,arr):#符合和数字合并
    temp=arr[:]
    l=0
    for i in 1,3,5:
        temp.insert(i,fuhao[l])
        l+=1
    return temp

def kuohao(fuh_arr):#加括号
    onefuhao=['(',')']
    tem=fuh_arr[:]#注意这里[:]，这样才是复制列表
    l=0
    for i in 0,4:
        tem.insert(i,onefuhao[l])
        l+=1
    tem="".join([str(x) for x in tem])
    if eval(tem)-24 ==0:
        ans.append(tem)
    print(tem)

    tem=fuh_arr[:]
    l=0
    for i in 0,6:
        tem.insert(i,onefuhao[l])
        l+=1
    tem="".join([str(x) for x in tem])
    if eval(tem)-24 ==0:
        ans.append(tem)
    print(tem)

    tem=fuh_arr[:]
    l=0
    for i in 2,6:
        tem.insert(i,onefuhao[l])
        l+=1
    tem="".join([str(x) for x in tem])
    if eval(tem)-24 ==0:
        ans.append(tem)
    print(tem)

    tem=fuh_arr[:]
    l=0
    for i in 2,8:
        tem.insert(i,onefuhao[l])
        l+=1
    tem="".join([str(x) for x in tem])
    if eval(tem)-24 ==0:
        ans.append(tem)
    print(tem)

    tem=fuh_arr[:]
    l=0
    for i in 4,8:
        tem.insert(i,onefuhao[l])
        l+=1
    tem="".join([str(x) for x in tem]) 
    if eval(tem)-24 ==0:
        ans.append(tem)
    print(tem)

    twofuhao=['(',')','(',')']
    tem=fuh_arr[:]
    l=0
    for i in 0,4,6,10:
        tem.insert(i,twofuhao[l])
        l+=1
    tem="".join([str(x) for x in tem])
    if eval(tem)-24 ==0:
        ans.append(tem)
    print(tem)

    twofuhao=['(','(',')',')']

    tem=fuh_arr[:]
    l=0
    for i in 0,1,5,8:
        tem.insert(i,twofuhao[l])
        l+=1
    tem="".join([str(x) for x in tem])
    if eval(tem)-24 ==0:
        ans.append(tem)
    print(tem)

    tem=fuh_arr[:]
    l=0
    for i in 0,3,7,8:
        tem.insert(i,twofuhao[l])
        l+=1
    tem="".join([str(x) for x in tem])
    if eval(tem)-24 ==0:
        ans.append(tem)
    print(tem)

    tem=fuh_arr[:]
    l=0
    for i in 2,3,7,10:
        tem.insert(i,twofuhao[l])
        l+=1
    tem="".join([str(x) for x in tem])
    if eval(tem)-24 ==0:
        ans.append(tem)
    print(tem)

    tem=fuh_arr[:]
    l=0
    for i in 2,5,9,10:
        tem.insert(i,twofuhao[l])
        l+=1
    tem="".join([str(x) for x in tem])
    if eval(tem)-24 ==0:
        ans.append(tem)
    print(tem)

arr = [1,14,3,2]
op=['+','-','*']

new=fuhao_hebin_arr(op,arr)
print(new)
kuohao(new)

s="".join([str(x) for x in temp])#列表转字符串

print(ans)

# print(eval(s))
# print(new)
# dfs(0)
# print(arr)
# print(num_qpl)
